<div [@routerTransition]>
  <div class="m-subheader">
    <div class="d-flex align-items-center">
      <div class="mr-auto col-xs-6">
        <h3 class="m-subheader__title m-subheader__title--separator">
          <span>文件管理</span>
        </h3>
        <span class="m-section__sub"> 文件管理 </span>
      </div>
      <div class="col-xs-8 text-right mt-3 mt-md-0">
        <div class="btn-group dropdown mr-2" dropdown>
          <button dropdownToggle class="dropdown-toggle btn btn-outline-success">
              <i class="far fa-file-excel"></i><span class="caret"></span> Excel操作
          </button>
          <ul class="dropdown-menu dropdown-menu-right dropdown-excel-operations" *dropdownMenu>
              <li>
                  <a href="javascript:;"
                     (click)="exportToExcel()">
                      <i class="fa fa-download"></i>
                      {{'ExportToExcel' | localize}}
                  </a>
              </li>
              <li>
                <excel-import [showIcon]="true" [onlyLink]="true" [btnColor]="'success'" [btnText]="'导入文件'" (onUpload)="onUpload($event)"></excel-import>
              </li>
          </ul>
      </div>
        <button (click)="createOrEditTechFileInfo.show()" class="btn btn-primary">
          <i class="fa fa-plus"> </i> 新建文件
        </button>
      </div>
    </div>
  </div>
  <div class="m-content">
    <div class="m-portlet m-portlet--mobile">
      <div class="m-portlet__body">
        <form class="horizontal-form" autocomplete="off">
          <div class="m-form m-form--label-align-right">
            <div class="row align-items-center m--margin-bottom-10">
              <div class="col-xl-12">
                <div class="form-group m-form__group align-items-center">
                  <div class="input-group">
                    <input [(ngModel)]="filterText" name="filterText" autofocus class="form-control m-input"
                      [placeholder]="l('SearchWithThreeDot')" type="text" />
                    <span class="input-group-btn">
                      <button (click)="search()" class="btn btn-primary" type="submit">
                        <i class="flaticon-search-1" [attr.aria-label]="l('Search')"></i>
                      </button>
                    </span>
                  </div>
                </div>
              </div>
            </div>
            <div class="row m--margin-bottom-10" [hidden]="!advancedFiltersAreShown">
              <div class="col-md-4">
                <div class="form-group">
                  <select #techFileInfoTypeCombobox name="sourceName" class="form-control bs-select"
                    [(ngModel)]="filetype">
                    <option value="-1">按文件类型搜索</option>
                    <option *ngFor="let Item of filetypes" [value]="Item.value">{{Item.displayText}}
                    </option>
                  </select>
                </div>
              </div>
              <div class="col-md-4">
                <div class="form-group">
                  <select #securityTypeCombobox name="sourceName" class="form-control bs-select" [(ngModel)]="security">
                    <option value="-1">按密级搜索</option>
                    <option *ngFor="let Item of securitys" [value]="Item.value">{{Item.displayText}}
                    </option>
                  </select>
                </div>
              </div>
              <div class="col-md-4">
                <div class="form-group">
                  <select #stageTypeCombobox name="sourceName" class="form-control bs-select" [(ngModel)]="stage">
                    <option value="-1">按阶段搜索</option>
                    <option *ngFor="let Item of stages" [value]="Item.value">{{Item.displayText}}</option>
                  </select>
                </div>
              </div>
            </div>
            <div class="row m--margin-bottom-10" [hidden]="!advancedFiltersAreShown">
              <div class="col-md-4">
                <div class="form-group">
                  <date-range-empty-picker placeholder="选择日期范围" [(startDate)]="startFilterDate" [(endDate)]="endFilterDate"></date-range-empty-picker>
                </div>
              </div>
            </div>

            <div class="row margin-bottom-10">
              <div class="col-sm-12">
                <span class="clickable-item text-muted" *ngIf="!advancedFiltersAreShown"
                  (click)="advancedFiltersAreShown=!advancedFiltersAreShown"><i class="fa fa-angle-down"></i>
                  {{"ShowAdvancedFilters" | localize}}</span>
                <span class="clickable-item text-muted" *ngIf="advancedFiltersAreShown"
                  (click)="advancedFiltersAreShown=!advancedFiltersAreShown"><i class="fa fa-angle-up"></i>
                  {{"HideAdvancedFilters" | localize}}</span>
              </div>
            </div>
          </div>
        </form>

        <div class="row align-items-center">
          <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
            <tabset class="tab-container tabbable-line">
              <tab customClass="m-tabs__item" (select)="selectType(1)">
                <span *tabHeading>
                  有效文件 &nbsp;<span class='m-badge m-badge--success'>
                    {{primengTableHelper.totalRecordsCount}}
                  </span>
                </span>
                <p-table #dataTable (onLazyLoad)="getModels($event)" [value]="primengTableHelper.records"
                  rows="{{primengTableHelper.defaultRecordsCountPerPage}}" [paginator]="false" [lazy]="true"
                  [scrollable]="true" ScrollWidth="100%" [responsive]="primengTableHelper.isResponsive"
                  [resizableColumns]="primengTableHelper.resizableColumns">
                  <ng-template pTemplate="header">
                    <tr>
                      <th style="width:140px">操作</th>
                      <th pSortableColumn="FileName">
                        文件名称
                        <p-sortIcon field="FileName"></p-sortIcon>
                      </th>
                      <th pSortableColumn="TechFileInfoType">
                        文件类型
                        <p-sortIcon field="TechFileInfoType"></p-sortIcon>
                      </th>
                      <th pSortableColumn="StageType">
                        阶段
                        <p-sortIcon field="StageType"></p-sortIcon>
                      </th>
                      <th pSortableColumn="SecurityType">
                        密级
                        <p-sortIcon field="SecurityType"></p-sortIcon>
                      </th>
                      <th pSortableColumn="CompanyCodesStr">
                        分发单位
                        <p-sortIcon field="CompanyCodesStr"></p-sortIcon>
                      </th>
                      <th>
                        实际分发单位
                      </th>
                      <th pSortableColumn="ModelName">
                        型号
                        <p-sortIcon field="ModelName"></p-sortIcon>
                      </th>
                      <th pSortableColumn="DrawingCode">
                        图号
                        <p-sortIcon field="DrawingCode"></p-sortIcon>
                      </th>
                      <th pSortableColumn="DrawingName">
                        图号名称
                        <p-sortIcon field="DrawingName"></p-sortIcon>
                      </th>
                      <th pSortableColumn="ParagraphNo">
                        部段号
                        <p-sortIcon field="ParagraphNo"></p-sortIcon>
                      </th>
                      <th>
                        更改单号
                      </th>
                    </tr>
                  </ng-template>
                  <ng-template pTemplate="body" let-record="$implicit">
                    <tr>
                      <td style="width: 140px">
                        <div class="btn-group dropdown" dropdown container="body">
                          <button dropdownToggle class="dropdown-toggle btn btn-sm btn-primary">
                            <i class="fa fa-cog"></i><span class="caret"></span> {{"Actions" | localize}}
                          </button>
                          <ul class="dropdown-menu" *dropdownMenu>
                            <li>
                              <a href="javascript:;"
                                (click)="createOrEditTechFileInfo.show(record.id)">{{'Edit' | localize}}</a>
                            </li>
                            <li>
                              <a href="javascript:;" (click)="alterationItem.show(record.id)">变更记录</a>
                            </li>
                            <li>
                              <a href="javascript:;" (click)="dispenseTechFileInfo.show(record.id)">分发文件</a>
                            </li>
                            <li>
                              <a href="javascript:;" (click)="deleteModel(record.id)">删除</a>
                            </li>
                          </ul>
                        </div>
                      </td>

                      <td>
                        <span class="ui-column-title">文件名称</span>
                        {{ record.fileName}}
                      </td>
                      <td>
                        <span class="ui-column-title">文件类型</span>
                        {{ record.techFileInfoTypeName}}
                      </td>
                      <td>
                        <span class="ui-column-title">阶段</span>
                        {{ record.stage}}
                      </td>
                      <td>
                        <span class="ui-column-title">密级</span>
                        {{ record.security}}
                      </td>
                      <td>
                        <span class="ui-column-title">分发单位</span>
                        {{ record.companyCodesStr}}
                      </td>
                      <td>
                        <span class="ui-column-title">实际分发单位</span>
                        {{ record.realCompanyCodesStr}}
                      </td>
                      <td>
                        <span class="ui-column-title">型号</span>
                        {{ record.modelName}}
                      </td>
                      <td>
                        <span class="ui-column-title">图号</span>
                        {{ record.drawingCode}}
                      </td>
                      <td>
                        <span class="ui-column-title">图号名称</span>
                        {{ record.drawingName}}
                      </td>
                      <td>
                        <span class="ui-column-title">部段号</span>
                        {{ record.paragraphNo}}
                      </td>
                      <td>
                        <span class="ui-column-title">更改单号</span>
                        {{ record.alterationInvoiceCode}}
                      </td>
                    </tr>
                  </ng-template>
                </p-table>
                <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
                  {{'NoData' | localize}}
                </div>
                <div class="primeng-paging-container">
                  <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                    (onPageChange)="getModels($event)" [totalRecords]="primengTableHelper.totalRecordsCount"
                    [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">

                  </p-paginator>
                  <span class="total-records-count">
                    {{'TotalRecordsCount' | localize:primengTableHelper.totalRecordsCount}}
                  </span>
                </div>
              </tab>

              <tab customClass="m-tabs__item" (select)="selectType(2)">
                <span *tabHeading>
                  无效文件 &nbsp;<span class='m-badge m-badge--danger'>
                    {{primengTableHelper1.totalRecordsCount}}
                  </span>
                </span>
                <p-table #dataTable1 (onLazyLoad)="getModels1($event)" [value]="primengTableHelper1.records"
                  rows="{{primengTableHelper1.defaultRecordsCountPerPage}}" [paginator]="false" [lazy]="true"
                  [scrollable]="true" ScrollWidth="100%" [responsive]="primengTableHelper1.isResponsive"
                  [resizableColumns]="primengTableHelper1.resizableColumns">
                  <ng-template pTemplate="header">
                    <tr>
                      <th pSortableColumn="FileName">
                        文件名称
                        <p-sortIcon field="FileName"></p-sortIcon>
                      </th>
                      <th pSortableColumn="TechFileInfoType">
                        文件类型
                        <p-sortIcon field="TechFileInfoType"></p-sortIcon>
                      </th>
                      <th pSortableColumn="StageType">
                        阶段
                        <p-sortIcon field="StageType"></p-sortIcon>
                      </th>
                      <th pSortableColumn="SecurityType">
                        密级
                        <p-sortIcon field="SecurityType"></p-sortIcon>
                      </th>
                      <th pSortableColumn="CompanyCodesStr">
                        分发单位
                        <p-sortIcon field="CompanyCodesStr"></p-sortIcon>
                      </th>
                      <th>
                        实际分发单位
                      </th>
                      <th pSortableColumn="ModelName">
                        型号
                        <p-sortIcon field="ModelName"></p-sortIcon>
                      </th>
                      <th pSortableColumn="DrawingCode">
                        图号
                        <p-sortIcon field="DrawingCode"></p-sortIcon>
                      </th>
                      <th pSortableColumn="DrawingName">
                        图号名称
                        <p-sortIcon field="DrawingName"></p-sortIcon>
                      </th>
                      <th pSortableColumn="ParagraphNo">
                        部段号
                        <p-sortIcon field="ParagraphNo"></p-sortIcon>
                      </th>
                      <th>
                        更改单号
                      </th>
                    </tr>
                  </ng-template>
                  <ng-template pTemplate="body" let-record="$implicit">
                    <tr>
                      <td>
                        <span class="ui-column-title">文件名称</span>
                        {{ record.fileName}}
                      </td>
                      <td>
                        <span class="ui-column-title">文件类型</span>
                        {{ record.techFileInfoTypeName}}
                      </td>
                      <td>
                        <span class="ui-column-title">阶段</span>
                        {{ record.stage}}
                      </td>
                      <td>
                        <span class="ui-column-title">密级</span>
                        {{ record.security}}
                      </td>
                      <td>
                        <span class="ui-column-title">分发单位</span>
                        {{ record.companyCodesStr}}
                      </td>
                      <td>
                        <span class="ui-column-title">实际分发单位</span>
                        {{ record.realCompanyCodesStr}}
                      </td>
                      <td>
                        <span class="ui-column-title">型号</span>
                        {{ record.modelName}}
                      </td>
                      <td>
                        <span class="ui-column-title">图号</span>
                        {{ record.drawingCode}}
                      </td>
                      <td>
                        <span class="ui-column-title">图号名称</span>
                        {{ record.drawingName}}
                      </td>
                      <td>
                        <span class="ui-column-title">部段号</span>
                        {{ record.paragraphNo}}
                      </td>
                      <td>
                        <span class="ui-column-title">更改单号</span>
                        {{ record.alterationInvoiceCode}}
                      </td>
                    </tr>
                  </ng-template>
                </p-table>
                <div class="primeng-no-data" *ngIf="primengTableHelper1.totalRecordsCount == 0">
                  {{'NoData' | localize}}
                </div>
                <div class="primeng-paging-container">
                  <p-paginator [rows]="primengTableHelper1.defaultRecordsCountPerPage" #paginator1
                    (onPageChange)="getModels1($event)" [totalRecords]="primengTableHelper1.totalRecordsCount"
                    [rowsPerPageOptions]="primengTableHelper1.predefinedRecordsCountPerPage">

                  </p-paginator>
                  <span class="total-records-count">
                    {{'TotalRecordsCount' | localize:primengTableHelper1.totalRecordsCount}}
                  </span>
                </div>
              </tab>
            </tabset>
          </div>
        </div>
      </div>
    </div>
  </div>
  <createOrEditTechFileInfo #createOrEditTechFileInfo (modalSave)="reloadPage()"></createOrEditTechFileInfo>
  <alterationItem #alterationItem></alterationItem>
  <dispenseTechFileInfo #dispenseTechFileInfo (modalSave)="reloadPage()"></dispenseTechFileInfo>
</div>